package de.sup.scs.prototyp.client.ui.main;

import com.google.gwt.event.shared.EventBus;
import com.google.gwt.event.shared.GwtEvent.Type;
import com.google.inject.Inject;
import com.gwtplatform.mvp.client.Presenter;
import com.gwtplatform.mvp.client.View;
import com.gwtplatform.mvp.client.annotations.ContentSlot;
import com.gwtplatform.mvp.client.annotations.ProxyCodeSplit;
import com.gwtplatform.mvp.client.proxy.PlaceManager;
import com.gwtplatform.mvp.client.proxy.Proxy;
import com.gwtplatform.mvp.client.proxy.RevealContentHandler;
import com.gwtplatform.mvp.client.proxy.RevealRootLayoutContentEvent;
import de.sup.scs.prototyp.client.ui.footer.FooterPresenter;
import de.sup.scs.prototyp.client.ui.title.TitlePresenter;

public class MainPagePresenter extends Presenter<MainPagePresenter.MyView, MainPagePresenter.MyProxy>{

    @ContentSlot
    public static final Type<RevealContentHandler<?>> TITLE = new Type<RevealContentHandler<?>>();

    @ContentSlot
    public static final Type<RevealContentHandler<?>> CONTENT = new Type<RevealContentHandler<?>>();

    @ContentSlot
    public static final Type<RevealContentHandler<?>> FOOTER = new Type<RevealContentHandler<?>>();

    @ProxyCodeSplit
    public interface MyProxy extends Proxy<MainPagePresenter> {}
    public interface MyView extends View {}

    private final TitlePresenter titlePresenter;
    private final FooterPresenter footerPresenter;


    @Inject
    public MainPagePresenter(EventBus eventBus, MyView view, MyProxy proxy, PlaceManager placeManager, TitlePresenter titlePresenter, FooterPresenter footerPresenter) {
        super(eventBus, view, proxy);
        this.titlePresenter = titlePresenter;
        this.footerPresenter = footerPresenter;
    }

    @Override
    protected void revealInParent() {
        RevealRootLayoutContentEvent.fire(this, this);
    }

    @Override
    protected void onReveal(){
        super.onReveal();
        setInSlot(TITLE, titlePresenter);
        setInSlot(FOOTER, footerPresenter);
    }
}
